# coding=utf-8

from application import redis
from app.json.redis.match import MatchPlayer
from app.model.redis.match import Match


def enter_room(token, user, user_cash):
    result = None
    user_id = token.split("#")[1] if "#" in token else 0
    if user_id == 0:
        return result

    match_player = MatchPlayer(user, user_cash)
    redis.set(Match.match_player.key % user_id, match_player.getJsonToRedis())
    result = match_player.getJson()
    return result